package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：郑皓
 * 创建时间：2017/1/23 11:27
 * 修改备注：
 * ================================================
 */
public class BusinessRealTimePrice {

    /**
     * 实时价格列表接口
     *
     * @param activity
     * @param marketCode  批发市场编码
     * @param minTypeCode 农作物编码
     * @param offset
     * @param limit
     * @param handler
     */
    public static void getRealPriceList(Activity activity, String marketCode, String minTypeCode, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("marketCode", marketCode);
        params.put("minTypeCode", minTypeCode);
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_REAL_PRICE_LIST, "", params, handler,
                MSG.MSG_GET_REAL_PRICE_LIST_SUCCESS, MSG.MSG_GET_REAL_PRICE_LIST_FIELD);

    }

    /**
     * 实时价格列表接口New
     *
     * @param activity
     * @param provinceCode 省CODE
     * @param cityCode     市CODE
     * @param countyCode   区CODE
     * @param minTypeCode  农作物编码
     * @param offset
     * @param limit
     * @param handler
     */
    public static void getRealPriceListNew(Activity activity, String provinceCode, String cityCode, String countyCode, String minTypeCode, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("provinceCode", provinceCode);
        params.put("cityCode", cityCode);
        params.put("countyCode", countyCode);
        params.put("minTypeCode", minTypeCode);
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_REAL_PRICE_LIST, "", params, handler,
                MSG.MSG_GET_REAL_PRICE_LIST_SUCCESS, MSG.MSG_GET_REAL_PRICE_LIST_FIELD);

    }

    /**
     * 根据省市区获取市场list
     *
     * @param activity
     * @param provincecode 省编码
     * @param citycode     市编码
     * @param countycode   区县编码
     * @param handler
     */
    public static void getMarketList(Activity activity, String provincecode, String citycode, String countycode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("provincecode", provincecode);
        params.put("citycode", citycode);
        params.put("countycode", countycode);

        OkHttpUtil.post(activity, URL.URL_GET_MARKET_LIST, "", params, handler,
                MSG.MSG_GET_MARKET_LIST_SUCCESS, MSG.MSG_GET_MARKET_LIST_FIELD);

    }

    /**
     * 根据实时价格ID获取实时价格详情
     *
     * @param activity
     * @param id           实时价格ID
     * @param redateTime   起止时间
     * @param backdateTime 结束时间
     * @param type         type=0按周1按月其他时按日期
     * @param standard     农产品的规格code
     * @param packing      农产品的包装方式code
     * @param storageMode  农产品的储存方式code
     * @param handler
     */
    public static void realPriceDetailsForApp(Activity activity, String id, String redateTime, String backdateTime,
                                              String type, String standard, String packing, String storageMode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);
        params.put("redateTime", redateTime);
        params.put("backdateTime", backdateTime);
        params.put("type", type);
        params.put("standard", standard);
        params.put("packing", packing);
        params.put("storageMode", storageMode);
        params.put("offset", "1");
        params.put("limit", "10");

        OkHttpUtil.post(activity, URL.URL_REAL_PRICE_DETAILS_FOR_APP, "请稍后...", params, handler,
                MSG.MSG_REAL_PRICE_DETAILS_FOR_APP_SUCCESS, MSG.MSG_REAL_PRICE_DETAILS_FOR_APP_FIELD);

    }

    /**
     * 根据实时价格ID获取实时价格详情表格
     *
     * @param activity
     * @param id           实时价格ID
     * @param redateTime   起止时间
     * @param backdateTime 结束时间
     * @param type         type=0按周1按月其他时按日期
     * @param handler
     */
    public static void priceDetailsForApp(Activity activity, String id, String redateTime, String backdateTime,
                                          String type, String standard, String packing, String storageMode,
                                          String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);
        params.put("redateTime", redateTime);
        params.put("backdateTime", backdateTime);
        params.put("type", type);
        params.put("standard", standard);
        params.put("packing", packing);
        params.put("storageMode", storageMode);
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_DETAILS_LIST_FOR_APP, "", params, handler,
                MSG.MSG_DETAILS_LIST_FOR_APP_SUCCESS, MSG.MSG_DETAILS_LIST_FOR_APP_FIELD);

    }


    /**
     * 查询农产品二级分类信息
     *
     * @param activity
     * @param handler
     */
    public static void getProductType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_GET_PRODUCT_TYPE, "", params, handler,
                MSG.MSG_GET_PRODUCT_TYPE_SUCCESS, MSG.MSG_GET_PRODUCT_TYPE_FIELD);

    }

    /**
     * 获取实时价格统计列表
     *
     * @param activity
     * @param farmProductCode 二级code
     * @param handler
     */
    public static void getProducePriceStatisticsList(Activity activity, String farmProductCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("farmProductCode", farmProductCode);

        OkHttpUtil.post(activity, URL.URL_GET_PRODUCE_PRICE_STATISTICS_LIST, "", params, handler,
                MSG.MSG_GET_PRODUCE_PRICE_STATISTICS_LIST_SUCCESS, MSG.MSG_GET_PRODUCE_PRICE_STATISTICS_LIST_FIELD);

    }


    /**
     * 省详情价格列表
     *
     * @param activity
     * @param farmProductCode
     * @param provinceCode
     * @param handler
     */
    public static void getProducePriceStatisticsDetails(Activity activity, String farmProductCode, String provinceCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("farmProductCode", farmProductCode);
        params.put("provinceCode", provinceCode);

        OkHttpUtil.post(activity, URL.URL_GET_PRODUCE_PRICE_STATISTICS_DETAILS, "", params, handler,
                MSG.MSG_GET_PRODUCE_PRICE_STATISTICS_DETAILS_SUCCESS, MSG.MSG_GET_PRODUCE_PRICE_STATISTICS_DETAILS_FIELD);

    }

    /**
     * 获取分类 返回1级分类
     *
     * @param activity
     * @param handler
     */
    public static void getTopLevelType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("pcode", "-1");

        OkHttpUtil.post(activity, URL.URL_GET_TOP_LEVEL_TYPE, "", params, handler,
                MSG.MSG_GET_TOP_LEVEL_ONE_SUCCESS, MSG.MSG_GET_TOP_LEVEL_ONE_FIELD);

    }

    /**
     * 获取分类
     *
     * @param activity
     * @param pCode    父编码
     * @param handler
     */
    public static void getTopLevelType(Activity activity, String pCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("pcode", pCode);

        OkHttpUtil.post(activity, URL.URL_GET_TOP_LEVEL_TYPE, "", params, handler,
                MSG.MSG_GET_TOP_LEVEL_TYPE_SUCCESS, MSG.MSG_GET_TOP_LEVEL_TYPE_FIELD);

    }

    /**
     * 实时价格顶部默认分类
     *
     * @param activity
     * @param handler
     */
    public static void getTopDefaultType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_GET_TOP_DEFAULT_TYPE, "", params, handler,
                MSG.MSG_GET_TOP_DEFAULT_TYPE_SUCCESS, MSG.MSG_GET_TOP_DEFAULT_TYPE_FIELD);

    }

    /**
     * 实时价格列表
     *
     * @param activity
     * @param farmProductCode
     * @param produceCode
     * @param handler
     */
    public static void getProducePriceStatisticsListV2(Activity activity, String farmProductCode, String produceCode, String page, String limit, Handler handler) {


        HttpParams params = new HttpParams();
        params.put("farmProductCode", farmProductCode);
        params.put("produceCode", produceCode);
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_PRICE_V2_LIST, "", params, handler,
                MSG.MSG_GET_PRICE_V2_LIST_SUCCESS, MSG.MSG_GET_PRICE_V2_LIST_FIELD);

    }


    /**
     * 实时价格详情
     *
     * @param activity
     * @param countyCode
     * @param produceCode
     * @param handler
     */
    public static void getProducePriceStatisticsDetailsV2(Activity activity,String farmProductCode, String produceCode, String countyCode, Handler handler) {


        HttpParams params = new HttpParams();
        params.put("farmProductCode", farmProductCode);
        params.put("produceCode", produceCode);
        params.put("countyCode", countyCode);


        OkHttpUtil.post(activity, URL.URL_GET_PRICE_V2_DETAILS, "", params, handler,
                MSG.MSG_GET_PRICE_V2_DETAILS_SUCCESS, MSG.MSG_GET_PRICE_V2_DETAILS_FIELD);

    }

    /**
     * 实时价格分类搜索
     *
     * @param activity
     * @param keyWords
     * @param handler
     */
    public static void getProductTypeByKeyWords(Activity activity, String keyWords, int page, int limit ,Handler handler) {


        HttpParams params = new HttpParams();
        params.put("keyWords", keyWords);
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_GET_PRODUCT_TYPE_BY_KEY_WORDS, "", params, handler,
                MSG.MSG_GET_PRODUCT_TYPE_BY_KEY_WORDS_SUCCESS, MSG.MSG_GET_PRODUCT_TYPE_BY_KEY_WORDS_FIELD);

    }

}
